package xyz.eden.cloud.common.web.support.domain.ability;



import xyz.eden.cloud.common.web.support.domain.ability.model.BaseInfo;
import xyz.eden.cloud.common.web.support.domain.ability.model.BaseQuery;
import xyz.eden.cloud.common.web.support.domain.ability.model.PageInfo;
import xyz.eden.cloud.common.web.support.domain.gateway.BaseQueryGateway;

import java.util.List;

public interface BaseQueryDomainService<Model extends BaseInfo, Query extends BaseQuery,
        QueryGateway extends BaseQueryGateway<Model, Query>> {


    default Model getInfoById(Long id) throws Exception {
        BaseQueryGateway<Model, Query> queryGateway = this.getQueryGateway();
        return queryGateway.getInfoById(id);
    }

    default List<Model> getInfoByParam(Query query) throws Exception {
        BaseQueryGateway<Model, Query> queryGateway = this.getQueryGateway();
        return queryGateway.getInfoByParam(query);
    }

    default PageInfo<Model> getPageInfoByParam(int pageNumber, int pageSize, Query query) throws Exception {
        BaseQueryGateway<Model, Query> queryGateway = this.getQueryGateway();
        return queryGateway.getPageInfoByParam(pageNumber, pageSize, query);
    }

    QueryGateway getQueryGateway();
}
